feat: add idempotent ledger checkpoint system - #650
Merged
Chucks1093 merged 3 commits intoJul 27, 2026
Conversation
- Add local setup guide with prerequisites, step-by-step instructions, and troubleshooting - Add API endpoint reference with all public endpoints, auth requirements, and sample responses - Cross-link both documents for easy navigation Closes accesslayerorg#598
- Add LedgerCheckpoint Prisma model with ledger, lastProcessedEventIndex, batchHash, completedAt - Create checkpoint service with write, read, validate, and resume functions - Non-blocking checkpoint writes with 5s timeout - Batch hash mismatch detection triggers warn log and reprocess - Integrate checkpointing into event processor with ledger-grouped processing - Add unit and integration tests for checkpoint operations Closes accesslayerorg#632
Member
|
Nice work on this. The checkpoint system is a clean solution. Grouping events by ledger and writing the checkpoint after each batch makes restarts safe without any complex state to manage. The 5s timeout on checkpoint writes is a good call too, it keeps the main flow from stalling if the write is slow. Good test coverage as well. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📌 Summary
Adds a ledger checkpoint system to prevent duplicate event processing after indexer restarts.
🎯 Purpose / Motivation
When the indexer restarts mid-batch, it currently has no reliable mechanism to resume from the exact ledger and event offset. This causes duplicate trade records and gaps in trade history. A checkpoint system makes restart recovery deterministic and safe.
🛠️ Changes Made
LedgerCheckpointPrisma model with ledger, lastProcessedEventIndex, batchHash, completedAt🧪 How to Test
pnpm testto verify all tests passLedgerCheckpointmodel is in Prisma schema🔗 Related Issues
Closes #632
✅ Checklist